package notify

import (
	"APT/internal/library/paycloud"
	"context"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/gogf/gf/v2/util/guid"

	"APT/api/notify/test"
)

func (c *ControllerTest) PaycloudCardPay(ctx context.Context, req *test.PaycloudCardPayReq) (res *test.PaycloudCardPayRes, err error) {
	var (
		paycloudClient *paycloud.Client
		CreateWebOrder paycloud.CreateWebPayOrderResponse
		r              = ghttp.RequestFromCtx(ctx)
	)
	if paycloudClient, err = paycloud.NewClient(ctx); err != nil {
		return
	}
	paycloudClient.Endpoint = "https://open.n-age.co.jp/api/entry"
	paycloudClient.AppID = "wz715fc0d10ee9d156"
	paycloudClient.MerchantNo = "312100007235"
	paycloudClient.StoreNo = "4122000030"
	paycloudClient.SubAppid = ""
	paycloudClient.PrivateKey = "MIIEpAIBAAKCAQEAjD4k7gtcR5AlLv06LKXyeyJXXJ6mFmgeC9vOwA7LHPdTSdDRz/QF73qU3ntUrVsUVWpnMh98lkSUp7G01kahPrUFg2dtUYYOQEPClmfUaUivn9O3l9StKzFJd8VKLryYFs1rx2ZVKCKlwce+p1O7qRaOQqCpp8l2K2dCtoYzPfu3EV33+PiyeybO3fHhYDFihJtCDfoeEjHkQrlOQ4CF3+FtLFGbshV4g7iGyA9ZAK6fSZzucKEmPzmAjNz43rGlzCx7py0doU4+MgGINllU/ObbFgk/gd6wQ4abjYGYUaz5/XIM2h31wn2a6V/QebkpXrhW1BQs/nu2akpkNDuTyQIDAQABAoIBADMtinSEGMzUwX0AU/ZvKKnewlq+WoXawPw63pwfyedsKizJ04c72d6msSTvhNsuXaE+DyKvctuzczwvEXsQk0866CQn3jDd5t103NHeWhmBuPVuYZU6u2cDuXfHu2aK1EWd+TLvGSxoWGz644xUdisiXA/caY0da84zBJlvJ8v6Ps9ZzDHbe+2y3XR1cFVqhDMbssvA0SEXC1OsqkHa4qPsup7dH2IwOZSoYgIYHI3oZjRQKaXixmtG2clBp1LFxIR6X8r2xsFaoeJuuUcF4tWeXZgUrrKpdORi8qeqsGIz4sDURjHoZjCwiMmACge5Q4Vlb8JO4py68Rzp0eJyhsECgYEA5hp3dC9z4lVi97sLDXhF89MNyPAt0SeXoQ3NtaT7VCCDV62pB7Vk2PndeQMtbalQCKfiA4uY38ow9kaBOxI3IMpNthBe0s+0FTSRby1YuiC5W6Lf/rTTEK3jLO/H5GABV5rOhyqU+MzVsMXNKMpIzPFlAZRqwRpLLezWRzpPle0CgYEAnAaxeFDoeIhBhBRbG+SMqYGOcACZ8FOhMcBUu528w86z3Gy4nDcYipd+PelA/IgrjMa9uPLbh1hVK5s6CeEPyRq3NNrbSkLAXFDLjpc0eon1CAIk2ylbLmaVssCFVndMRY0qfYb1yKtBI56pWlGBy6LLCR+mSTbPECJk7RrB+c0CgYEA4ueid+37RmuRBl1pzsSVppSu+UDuzVtPiL/F5KNmO1U8b4+OKU3UvqnWnehmOcdGZuK2W2yjObt2gMSR1yBlQG5+J1UJTLUJDggiihGbdx+h6R056T+DCuWOKdfhs/CAIlVD58Iz2QyUhJbpcpnXJFG+msoyY218STNNMjvsExkCgYAO9oFchX3V2VNXJFCcey2WL+uGCDi7GHoT+Frn5zesG42aLP8DVDFRUTf1HgJydWifxot5SikNcMYyOV+2hNPruFkrg3WWSJKEB+eNlCifO8245+O69Ntets3SZ64h3az92ozhnujBRtMnZFbfZ4OoEMOh61waF1yCMpo1NuS1XQKBgQCPiBSz7paaWB9r1mc4t0QMpFLENuQECnsBHRn8sUy15Ij7NVo93k8plSuldvP4zzoIAX4SGsW9XYC7nEoc9Tc6Eo5Z9lzoIaeWXtyyTiF/zYrQNOMUDej1jwdFzgVvOAxiU/pHEb3R/jgiRN32nc7e1uguSb2SElKXi2t/++eMWg=="
	if CreateWebOrder, err = paycloudClient.WebOrder(ctx, &paycloud.CreateWebPayOrderParams{
		MerchantOrderNo: guid.S(),
		OrderAmount:     req.Amount,
	}); err != nil {
		return
	}
	r.Response.RedirectTo(CreateWebOrder.Data.PayUrl)
	return
}
